package com.qk.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qk.entity.OssCleanupRecord;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;

@Mapper
public interface OssCleanupRecordMapper extends BaseMapper<OssCleanupRecord> {

    /**
     * 获取最近一次清理记录
     */
    @Select("SELECT * FROM oss_cleanup_record ORDER BY create_time DESC LIMIT 1")
    OssCleanupRecord selectLatestRecord();

    @Insert("INSERT INTO oss_cleanup_record (last_cleanup_time, deleted_files, create_time) VALUES (#{now}, #{deletedCount}, #{now})")
    void saveCleanupRecord(LocalDateTime now, Integer deletedCount);
}